import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      //重定向
      redirect: "/article/manage",
      component: () => import("@/views/Home/Home.vue"),
      children: [
        { path: "/article/Category", component: () => import("@/views/Article/ArticleCategory.vue") },
        { path: "/article/manage", component: () => import("@/views/Article/ArticleManage.vue") },
        {
          path: "/user",
          redirect: "/user/info",
          children: [
            { path: "/user/info", component: () => import("@/views/User/UserInfo.vue") },
            { path: "/user/avatar", component: () => import("@/views/User/UserAvatar.vue") },
            { path: "/user/password", component: () => import("@/views/User/UserResetPassword.vue") },
          ],
        },
      ],
    },
    {
      path: "/login",
      name: "login",
      component: () => import("@/views/Login/Login.vue"),
    },
    {
      path: "/:pathMatch(.*)*",
      component: () => import("@/components/NotFound/NotFound.vue"),
    },
  ],
  // 滚动 - 控制页面导航后显示顶部
  scrollBehavior() {
    return {
      top: 0,
      left: 0,
    };
  },
});
export default router;
